package tk.mybatis.simple.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Param;

import tk.mybatis.simple.model.SysRole;
import tk.mybatis.simple.model.SysUser;

public interface UserMapper {
	
	 SysUser selectById(Long id);
	 
	 List<SysUser> selectAll();
	 
	 /**
	  * 根据用户 id 获取角色信息
	  * @param userId
	  * @return
	  */
	 List <SysRole> selectRolesByUserId(Long userId);
	 
	 /**
	  * 新增用户
	  */
	 int addUser(SysUser sysUser);
	 
	 /**
	  * 使用userGeneratedKeys 方式
	  * @param sysUser
	  * @return
	  */
	 int addUser2(SysUser sysUser);
	 
	 int updateById(SysUser sysUser);
	 
	 int deleteById(Long id);
	 
	 List<SysRole> selectRoleByUserIdAndRoleEnabled(
			 @Param("userId") Long userId, 
			 @Param("enabled") Integer enabled);
	 
	 List<SysUser> selectByUser(SysUser sysUser);
	 
	 int updateByIdSelective(SysUser sysUser);
	 
	 SysUser selectUserAndRoleById(Long id);
}
